/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ids;

import ids.dl.ClientsHandler;
import ids.dl.IClientsHandler;
import ids.dl.IServer;
import ids.dl.Server;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

/**
 *
 * @author isuru
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Registry registry;
        try {
            Server obj = new Server();
            IServer stub = (IServer) UnicastRemoteObject.exportObject(obj, 0);

            // Bind the remote object's stub in the registry
            registry = LocateRegistry.createRegistry(3232);
            registry.bind("IServer", stub);

            System.err.println("Server ready");
     
            ClientsHandler obj2 = new ClientsHandler();
            IClientsHandler stub2 = (IClientsHandler) UnicastRemoteObject.exportObject(obj2, 0);

            // Bind the remote object's stub in the registry
            //Registry registry = LocateRegistry.createRegistry(3232);
            registry.bind("IClientsHandler", stub2);

            System.err.println("ClientsHandler ready");
        } catch (Exception e) {
            System.err.println("ClientsHandler exception: " + e.toString());
            e.printStackTrace();
        }
        

//        try {
//            Registry registry = LocateRegistry.getRegistry("win7-pc");
//            IClientsHandler stub = (IClientsHandler) registry.lookup("IClientsHandler");
//            String response = stub.getCoordinatorUri();
//            System.out.println("response: " + response);
//        } catch (Exception e) {
//            System.err.println("Client exception: " + e.toString());
//            e.printStackTrace();
//        }
    }

}
